list in list python

30

l1 = [1,2,3]
l2 = [4,5,6]
l3 = [7,8,9]

lst = []

lst.append(l1)
lst.append(l2)
lst.append(l3)
print(lst)
class Solution:
    def twoSum(self, nums: List[int], target: int) -> List[int]:
# A list is a collection of items. 
# Lists are mutable: you can change their elements and their size.
# Similar to List<T> in C#, ArrayList<T> in Java, and array in JavaScript.

foo = [1, 2, True, "mixing types is fine"]
print(foo[0])
# Output - 1

foo[0] = 3
print(foo[0]) 
# Output - 3
board = []    
for i in range(6): # create a list with nested lists
    board.append([])
    for n in range(6):
        board[i].append("O") # fills nested lists with data

Comments

Submit
0 Comments